/*
 * @Description: main description
 * @Author: zhang zhen
 * @Date: 2023-01-14 14:31:06
 * @LastEditors: zhang zhen
 * @LastEditTime: 2023-01-16 09:35:54
 * @FilePath: /NestJs/nestjs-demo/src/boy/boy.service.ts
 */
import { Injectable } from '@nestjs/common';
import { Like, Repository } from 'typeorm';
import { InjectRepository } from '@nestjs/typeorm';
import { Boy } from './entities/boy.entities';

@Injectable()
export class BoyService {
  // constructor(@InjectRepository(Boy) private readonly boy:Repository<Boy>)

  getBoys() {
    return {
      code: 200,
      data: ['藤原拓海', '高城凉介'],
      message: '请求成功',
    };
  }

  addBoy() {
    return {
      code: 200,
      data: {
        name: '京二',
        id: 8,
      },
      message: '添加成功',
    };
  }

  getBoyById(id: number) {
    let newJson: any = {};
    switch (id) {
      case 1:
        newJson = { id: 1, name: '藤原拓海' };
        break;
      case 2:
        newJson = { id: 2, name: '高城凉介' };
        break;
    }
    return newJson;
  }

  // // 添加人
  // addNewPerson() {
  //   const data = new Boy();
  //   data.name = '777';
  //   data.age = 23;
  //   data.skill = 'play games';
  //   return this.boy.save(data);
  // }

  // // 删除人员
  // deleteUser(id: number) {
  //   return this.boy.delete(id);
  // }
}
